home *** CD-ROM | disk | FTP | other *** search
- ;==========================================================================;
- ; Initialization Routines ;
- ; ;
- ; Copyright 1983 by William E. Westfield. All rights reserved. ;
- ; Copyright 1986, 1987, 1988, 1991 by H. Roy Engehausen. ;
- ; All rights reserved. ;
- ; ;
- ; This software may be freely distributed and used, but it may not ;
- ; under any circumstances be sold by anyone other than the author. ;
- ; It may be distributed by a commercial company as long as it is ;
- ; for no cost. ;
- ;==========================================================================;
-
- ;--------------------------------------------------------------------------;
- ; Handle desqview stuff ;
- ;--------------------------------------------------------------------------;
-
- IF present_dv ; Only if desqview is wanted
-
- TEST parm_flag,parm_flag_d ; Desqview?
- JNZ dv_to_work ; Yes
-
- dv_store MACRO NUM
- dv_lbl = dv_hook&num
- MOV WORD PTR dv_lbl,AX
- MOV dv_lbl+2,AL
- ENDM
-
- dv_nop LABEL WORD
- NOP
- NOP
- MOV AX,dv_nop
-
- REPT dv_cnt
- dv_store %dv_cnt
- dv_cnt = dv_cnt - 1
- ENDM
-
- dv_to_work:
-
- ENDIF
-
- ;--------------------------------------------------------------------------;
- ; Initialize the buffer pool -- This starts to clobber the initialization ;
- ; code. We have to bury some jumps in the right places ;
- ;--------------------------------------------------------------------------;
-
- MOV AX,OFFSET buffer_start ;
- MOV CL,4 ;
- SHR AX,CL ;
- MOV BX,CS ;
- ADD AX,BX ; Get segment address of buffers
- MOV pool_start,AX ; Segment where the pool starts
- MOV free_buffer_head,AX ; Set head of the chain
- MOV ES,AX ; ES now head of chain
-
- MOV CL,buffer_count ; Number of buffers to build
- SUB CH,CH ; Clear top of register
- MOV DX,buffer_size_para ; Increment bewteen buffer addresses
- ADD AX,DX ; Next buffer address
-
- ;--------------------------------------------------------------------------;
- ; This little loop chains all the buffers together on the free list ;
- ;--------------------------------------------------------------------------;
-
- build_loop:
-
- MOV ES:buffer_next,AX ; Chain by buffer address
-
- MOV ES,AX ; ES now next buffer in sequence
-
- ADD AX,DX ; Calculate next buffer address
-
- LOOP build_loop ; Loop for all buffers
-
- MOV ES:buffer_next,0 ; Zero the last buffer
-
- ;--------------------------------------------------------------------------;
- ; Now snatch the BIOS comm vector ;
- ;--------------------------------------------------------------------------;
-
- CLI ; No interrupts while snatching!
-
- MOV AH,dos_get_vector ; DOS call #35H -- Get vector
- MOV AL,rs232_vector_no ; vector #
- INT dos_vector_no ; Do it
-
- MOV old_bios_vector,BX ; and save it
- MOV old_bios_vector+2,ES ;
-
- MOV AH,dos_set_vector ; DOS call #25H -- Set vector
- MOV AL,rs232_vector_no ; RS232 vector #
- MOV DX,OFFSET rsint ; Our vector address
- ; DS already points to correct segment
- INT dos_vector_no ; Do it
-
- ;--------------------------------------------------------------------------;
- ; Loop initializing each COM port ;
- ;--------------------------------------------------------------------------;
-
- MOV SI,OFFSET com_start ; Place to start the comm loop
-
- init_loop:
-
- MOV DI,com_init_count ; Get number of ports left to do
-
- ;--------------------------------------------------------------------------;
- ; Set the hardware interrupt vector ;
- ;--------------------------------------------------------------------------;
-
- MOV old_interrupt_vec_seg[DI],0 ; Start with a zero for segment
-
- MOV AL,hiv[SI] ; Get the hardware interrupt vector address
- MOV AH,dos_get_vector ; DOS call #35H -- Get vector
- INT dos_vector_no ; Do it
-
- MOV AX,ES ; Get the segment of the current vector
- MOV DX,DS ; Get our segment
- CMP DX,AX ; See if it is already us...
- JE init_interrupt_skip ; If it is, skip it
-
- MOV old_interrupt_vec_off[DI],BX ; Save previous hardware vectors
- MOV old_interrupt_vec_seg[DI],ES ; Save previous hardware vectors
-
- MOV AL,hiv[SI] ; Get the hardware interrupt vector address
- MOV AH,dos_set_vector ; DOS call #25H -- Set vector
- MOV DX,interrupt_vector[DI] ; Get our address
- INT dos_vector_no ; Do it
-
- init_interrupt_skip:
-
- MOV interrupt_vector[DI],SI ; Save the com block address here!
-
- MOV AX,DI ; Bump counter to next value
- INC AX ; Bump counter
- INC AX ; Twice for words
- MOV com_init_count,AX ; and then save it
-
- ;--------------------------------------------------------------------------;
- ; Fix up BIOS pointers ;
- ;--------------------------------------------------------------------------;
-
- MOV CX,baseaddr[SI] ; Get base address for chip
-
- SUB BH,BH ;
- MOV BL,comnumber[SI] ; Get the com number
- CMP BL,rs232_bios_max-1 ; Within the table?
- JA init_not_bios ; Nope, skip it
-
- SHL BL,1 ; * 2
- SUB AX,AX ; Get a zero
- MOV ES,AX ; Put in ES so data is in absolute 0
- MOV ES:rs232_bios_address[BX],CX ; Put address in BIOS table
-
- init_not_bios:
-
- ;--------------------------------------------------------------------------;
- ; Initialize the buffer addresses. ;
- ;--------------------------------------------------------------------------;
-
- CALL get_a_buffer ; Get a buffer (of course!)
- MOV buffer_r_a[SI],AX ; Put it away for receive
- MOV ES,AX ; Clear any chains
- MOV ES:buffer_next,0 ;
-
- ;--------------------------------------------------------------------------;
- ; If we have an 8250 or QuadPort or a 4 asyc port card with transmit ;
- ; buffering, get an extra buffer ;
- ;--------------------------------------------------------------------------;
-
- TEST options[SI],opt_trbuf ; Transmit buffering turned on?
- JZ init_buffer_not ; Nope... No extra buffer needed
-
- CMP chip[SI],chip_8250 ; Is this an 8250?
- JE init_buffer_textra ; Yep, lets do it
- CMP chip[SI],chip_qrqp ; Is this a QuadRam QuadPort?
- JE init_buffer_textra ; Yep, lets do it
- CMP chip[SI],chip_4apc ; Is this a 4 async port card?
- JNE init_buffer_not ; Nope... Skip
-
- init_buffer_textra:
-
- CALL get_a_buffer ; Get a buffer (of course!)
- MOV buffer_t_a[SI],AX ; Put it away for transmit
-
- TEST options[SI],opt_hdwhs ; Hardware handshaking desired?
- JZ init_buffer_not ; Nope... No signal needed
-
- MOV need_tmr,1 ; Handshaking/Transmit buffering
- ; require timer grab
-
- init_buffer_not:
-
- ;--------------------------------------------------------------------------;
- ; Initialize the buffer ring pointers ;
- ;--------------------------------------------------------------------------;
-
- SUB AX,AX ; Start of buffer is offset zero
- MOV buffer_r_in[SI],AX ; Put in the buffer pointers
- MOV buffer_r_out[SI],AX ; Put in the buffer pointers
- MOV buffer_t_in[SI],AX ; Put in the buffer pointers
- MOV buffer_t_out[SI],AX ; Put in the buffer pointers
-
- ;--------------------------------------------------------------------------;
- ; Enable the interrupts for this device ;
- ;--------------------------------------------------------------------------;
-
- TEST options[SI],opt_high_irq ; Slave 8259 involved?
- JNZ init_pic_slave ; Yep
-
- IN AL,pic_mask_port ; Set up 8259 master interupt controller
- AND AL,int_mask[SI] ; Enable the interrupts for this device
- OUT pic_mask_port,AL ;
- JMP SHORT init_pic_done ;
-
- init_pic_slave:
- IN AL,pic2_mask_port ; Set up 8259 slave interupt controller
- AND AL,int_mask[SI] ; Enable the interrupts for this device
- OUT pic2_mask_port,AL ;
- init_pic_done:
-
- ;--------------------------------------------------------------------------;
- ; Quad port init ;
- ;--------------------------------------------------------------------------;
-
- IF present_qrqp
- INCLUDE QRQPINI.ASM
- ENDIF
-
- ;--------------------------------------------------------------------------;
- ; buffer jump ;
- ;--------------------------------------------------------------------------;
-
- JMP mbbinit_buffer_jump1
- ORG buffer_start + 2*buffer_size ;
- mbbinit_buffer_jump1:
-
- ;--------------------------------------------------------------------------;
- ; 8250 init ;
- ;--------------------------------------------------------------------------;
-
- IF present_8250
- INCLUDE 8250INI.ASM
- ENDIF
-
- ;--------------------------------------------------------------------------;
- ; 8530 init ;
- ;--------------------------------------------------------------------------;
-
- IF present_8530
- INCLUDE 8530INI.ASM
- ENDIF
-
- ;--------------------------------------------------------------------------;
- ; Loop thru the next comm port ;
- ;--------------------------------------------------------------------------;
-
- MOV SI,com_next[SI] ; Pointer to next com port block
-
- CMP SI,0 ; Anything left to be done?
- JE com_done ; Nope...
- JMP init_loop ; Yep.. Loop back
- com_done:
-
- ;--------------------------------------------------------------------------;
- ; Now snatch the timer vector ;
- ;--------------------------------------------------------------------------;
-
- CMP need_tmr,0 ; Need timer?
- JE no_time_vector_init ; Nope.. Don't grab timer interrupt
-
- MOV AH,dos_get_vector ; DOS call #35H -- Get vector
- MOV AL,timer_vector_no ; vector #
- INT dos_vector_no ; Do it
-
- MOV timer_old,BX ; and save it
- MOV timer_old+2,ES ;
-
- MOV AH,dos_set_vector ; DOS call #25H -- Set vector
- MOV AL,timer_vector_no ; RS232 vector #
- MOV DX,OFFSET timer_int ; Our vector address
- ; DS already points to correct segment
- INT dos_vector_no ; Do it
-
- no_time_vector_init: ;
-
- ;--------------------------------------------------------------------------;
- ; Enable interrupts ;
- ;--------------------------------------------------------------------------;
-
- STI ; Enable CPU to receive interupts